<template>
    <div>
        <div class="main">
            <el-card class="box-card">
                <el-result icon="success" :title="text">
                    <template slot="extra">
                        <div style="width: 60vh;margin-top: 10px;margin-bottom: 30px;">
                            <el-row>
                                <el-col :span="6">

                                    <div class="result-content-text">
                                        <p>客观题成绩<br>
                                            <span>{{examInfo.systemScore}}分</span></p>
                                    </div>
                                </el-col>
                                <el-col :span="6">
                                    <div class="grid-content bg-purple">
                                        <div class="result-content-text">
                                            <p>考试成绩<br>
                                                <span>{{examInfo.paperScore}}分</span>
                                            </p>
                                        </div>
                                    </div>
                                </el-col>
<!--                                <el-col :span="6">-->
<!--                                    <div class="grid-content bg-purple">-->
<!--                                        <div class="result-content-text">-->
<!--                                            <p>交卷时间<br>-->
<!--                                                <span>{{examInfo.createTime}}</span></p>-->
<!--                                        </div>-->
<!--                                    </div>-->
<!--                                </el-col>-->
                                <el-col :span="6">
                                    <div class="grid-content bg-purple">
                                        <div class="result-content-text">
                                            <p>试卷满分<br>
                                                <span>{{examInfo.fullScore}}分</span></p>
                                        </div>
                                    </div>
                                </el-col>
                                <el-col :span="6">
                                    <div class="grid-content bg-purple">
                                        <div class="result-content-text last-result-content-text">

                                            <p>批改状态<br>
                                                <el-tag type="success" v-if="examInfo.status === 2">已完成</el-tag>
                                                <el-tag type="success" v-if="examInfo.status === 1">待批改</el-tag>
                                            </p>
                                        </div>
                                    </div>
                                </el-col>

                            </el-row>

                        </div>
                        <el-button type="primary" size="medium" @click="jump">{{btnText}}</el-button>
                    </template>
                </el-result>
            </el-card>
        </div>
    </div>
</template>
<style>
    body {
        background-color: #F7F7F7;
    }

    .box-card {
        margin: 100px auto;
        width: 60%;
        min-height: 60vh;
    }

    .result-content-text {
        border-right: 1px #ECEBEB solid;
        line-height: 30px;
    }

    .last-result-content-text {
        border-right: 0px;
    }
</style>
<script>
    import request from "../utils/request";

    export default {
        name: 'Result',
        data() {
            return {
                examInfo: {},
                doTimeStr: "",
                text:"",
                rollback:"",
                btnText:"返回",

            }
        },
        created() {
            if (this.$route.params.examInfo) {
                this.examInfo = this.$route.params.examInfo;
                this.text=this.$route.params.text;
                this.rollback=this.$route.params.rollback;
                if(this.rollback =="/checkPaper"){
                    this.btnText = "关闭"
                }
                if (this.examInfo.doTime >= 60) {
                    this.doTimeStr = "";
                    this.doTimeStr += this.examInfo.doTime / 60 + "分"
                    this.doTimeStr += this.examInfo.doTime % 60 + "秒"
                } else {
                    this.doTimeStr = "";
                    this.doTimeStr += this.examInfo.doTime % 60 + "秒"
                }
                //格式化时间
                let formatDate = (new Date(this.examInfo["createTime"])).Format("MM-dd hh:mm");
                this.examInfo["createTime"] = formatDate;
            } else {
                this.$message.error("出错");
            }
        },
        mounted() {
            history.pushState(null, null, document.URL);
            window.addEventListener('popstate', function () {
                history.pushState(null, null, document.URL);
            });
        },
        methods: {
            jump() {
                // this.$router.push({path: "/", name: '主页', params: {}});
                // this.$router.replace('/exam')
                if(this.rollback == "/checkPaper"){
                   window.close();
                }else{
                    window.location.href = 'http://localhost:8080'+this.rollback;
                }


            },

        }

    }
    ;
</script>
